package com.atguigu.springcloud.controller;

import com.atguigu.springcloud.entities.CommonResult;
import com.atguigu.springcloud.entities.Payment;
import com.atguigu.springcloud.service.PaymentFeignService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * Created with IntelliJ IDEA.
 *
 * @Auther: hjj
 * @Date: 2021/11/09/15:27
 * @Description:
 */
@RestController
@Slf4j
public class OrderFeignController {

    @Resource
    private PaymentFeignService paymentFeignService;

    @GetMapping("/consumer/payment/get/{id}")
    public CommonResult<Payment> getPayment(@PathVariable(value = "id") Long id){
        CommonResult<Payment> payment = paymentFeignService.getPaymentById(id);
        return payment;
    }

    @GetMapping(value = "/consumer/payment/feign/timeout")
    public String paymentFeignTime(){
        //openfeign-ribbon 客户端一般默认等待1秒
        return paymentFeignService.paymentFeignTimeout();
    }
}
